//
// Created by fys on 2020/5/14.
//

#include "common_ttcp.h"

int main(int argc, char* argv[])
{
    Options options;
    bzero(&options, sizeof(Options));
    int isServer = 0;
    for (int i = 1 ; i < argc ; i = i + 2)
    {
        if (strcmp("isServer", argv[i]) == 0 && strcmp("1", argv[i+1]) == 0)
        {
            isServer = 1;
        }
        if (strcmp("num", argv[i]) == 0)
        {
            options.number = atoi(argv[i + 1]);
            printf("num :%d \n", options.number);
        }
        if (strcmp("length", argv[i]) == 0)
        {
            options.length = atoi(argv[i + 1]);
            printf("length :%d \n", options.length);
        }
        if (strcmp("port", argv[i]) == 0)
        {
            options.port = atoi(argv[i + 1]);
            printf("port :%d \n", options.port);
        }
        if (strcmp("host", argv[i]) == 0)
        {
            printf("host :%s \n", argv[i + 1]);
            options.host = argv[i + 1];
        }
    }

    if (isServer)
    {
        receive(&options);
    }
    else
    {
        transmit(&options);
    }
}